package com.wangjiang.mario.admin.core.shiro.token;

import lombok.Data;
import org.apache.shiro.authc.AuthenticationToken;

@Data
public class JwtToken implements AuthenticationToken {

    private static final long serialVersionUID = 1L;
    private static final String BEARER = "Bearer ";
    // 密钥
    private String token;

    /**
     * token  带Bearer
     *
     * @param token
     */
    public JwtToken(String token) {
        if(token.startsWith(BEARER)) {
            this.token = token;
        } else {
            this.token = BEARER + token;
        }
    }

    @Override
    public Object getPrincipal() {
        return token;
    }

    @Override
    public Object getCredentials() {
        return token;
    }

    public void clear() {
        this.token = null;
    }
}
